var Res = {
	opt: null,
	actionSheetO:null,
	actionSheetT:null,
	count: 5, //每次下拉刷新个数
	defaultIMG: "student/students.png",
	gnTitle: function(opt) {
		Res.opt = opt;
		var html = '';
		if (opt.leftFn)
			Res.leftFn = opt.leftFn;
		else
			Res.leftFn = WinClose;
		Res.rightFn = opt.rightFn;
		Res.switchFn = opt.switchFn;
		Res.bottomFn = opt.bottomFn;
		// var content = "";
		if (opt.isSwitch) {
			html += '<div id="header" class="ub ub-ver ub-img1 ufp8 uw100">';
			if (opt.leftFn){
				html += '    <div id="leftBtn" class="uw2 ub ub-ac" ontouchstart="zy_touch()" onclick="Res.leftClick();">'+
					    '        <div class="uw1 uh2 ub-img im_back1 uml_1"></div>'+
					    '    </div>';
			}		    
			html += '<div class="ub-f1 ub_center ub">';
			for (var i=0; i<opt.items.length; ++i) {
				var selected = "";
				var upp65 = "";
				if (opt.items[i].url == "notice")
					upp65 = "upp65";

				if (GetLS("selectedNum")){
					if (i == GetLS("selectedNum"))
						selected = "selected";
				} else if (i == 0)
					selected = "selected";
				var icon_bottom = (opt.items[i].url == "activity"||opt.items[i].url == "attendActivity")?'<div class="ub-img im_bottom uh1 uw1 uml_p3 visib"></div>':'';
				html += '<div id="'+ opt.items[i].url +'" class="' + upp65 + ' ub ub-ac ub-pc up_title_item uml_p8f uw5 ub-f1 tx-c ' + selected + '" ontouchstart="zy_touch()" onclick="Res.switch(\''+ opt.items[i].num +'\',' + opt.items.length + ',' + opt.items[i].itemNum + ')">'+ opt.items[i].title + icon_bottom + '</div>';
			}
			html += '</div>';
			if (opt.items.length)
				html += '<div id="selectBorder" class="uhp1 bc_base" style="width:' + 75/opt.items.length + '%;margin-left:' + 100*GetLS("selectedNum")/opt.items.length + ';"></div>';
			if (opt.rightFn){
				html +=	'    <div id="rightBtn" class="uw4 ub_center ufp9" ontouchstart="zy_touch()" onclick="Res.rightClick();">';

				if (opt.rightTitle)
					html += '	<div class="ub ub-ac ub-pc uh1p5 hide c_wht" style="border-radius:0.2em;">'+ opt.rightTitle +'</div>';
				else
					html += '	<div class="uw2 ub ub-ac ub-pc uh1p5 ub_img im_'+ opt.rightImg +' hide"></div>';
			}	

			html += '    </div>'+
				    '</div>';
		} else {
		    html += '<div id="header" class="ub c_wht bc_base">'+
				    '    <div id="leftBtn" class="uw2 ub ub-ac" ontouchstart="zy_touch()" onclick="Res.leftClick();">'+
				    '        <div class="uw1 uh2 ub-img1 im_back1 uml_1"></div>'+
				    '    </div>'+
				    '    <div id="title" class="up_title  ub-f1 ut-s tx-c">'+ opt.title +'</div>'+
				    '    <div id="rightBtn" class="uw4 ub_center ufp9" ontouchstart="zy_touch()" onclick="Res.rightClick();">';
					if (opt.rightTitle)
						html += '	<div class="ub ub-ac ub-pc uh1p5 c_wht" style="border-radius:0.2em;">'+ opt.rightTitle +'</div>';
					else
						html += '	<div class="uw2 ub ub-ac ub-pc uh1p5 ub_img im_'+ opt.rightImg +'"></div>';
			html += '    </div>'+
				    '</div>';
		}
		if ($("#header").length)
			$("#header").remove();
		$("body").prepend(html);
		if (opt.isSwitch) {
		 //    var topMargin = $("#header").outerHeight();
		 //    uexWindow.openMultiPopover(content,"multiWindow", 0, 0, topMargin, $("#content").width(), $("#content").height(), '', 0, 0);
		 //    uexWindow.setSelectedPopOverInMultiWindow('multiWindow', 0);
			// uexWindow.cbOpenMultiPopover = opt.cb;
		}
	},
	leftClick: function() {
		Res.leftFn();
	},
	rightClick: function() {
		if (Res.rightFn)
			Res.rightFn();
	},
	switch: function(i,length,itemNum) {
		Res.borderSwitch(itemNum,length);
		var t = 100/length*itemNum + "%";
		SetLS("swipenum", itemNum);
		CCall('$(".linebox").css({"-webkit-transform":"translate(-'+t+')","-webkit-transition":"300ms linear"} )');
		var type = i;
		var $this = $(event.currentTarget);
		// var certypeFn = function(){ 
			// var ctypename = [CurrentUser.category==30?"查看全部":"Check all"];
			// var arr = ctypename.concat(addressArr)
			// ActionSheet(CurrentUser.category==30?"请选择地址":"Please select address", CurrentUser.category==30?"取消":"Cancel", arr, function(data){
				// var address = data>0?arr[data]:"";
				// if (i == 0)	
					// Event.init(address);
				// else if (i == 1)
					// Event.attendInit(address);
			// });
		// }	
		$(".im_bottom").addClass("visib");	
		if (i=="0"&&GetLS("tab").url=="event"){
			$this.children(".im_bottom").removeClass("visib");
			Res.actionSheetT = null;
			if (!Res.actionSheetO){
				Res.actionSheetO = true;
				return;
			}	
			certypeFn();
		} else if (i=="1"&&GetLS("tab").url=="event"){ 
			$this.children(".im_bottom").removeClass("visib");
			Res.actionSheetO = null;
			if (!Res.actionSheetT){
				Res.actionSheetT = true;
				return;
			}	
			certypeFn();
		} else { 
			Res.actionSheetO = null;
			Res.actionSheetT = null;
		}	
    },
    borderSwitch: function(itemNum,length){ 
    	$("#selectBorder").css("margin-left",100*itemNum/length + "%");
        $(".up_title_item").removeClass("selected");
        $("#header .up_title_item").eq(itemNum).addClass("selected");
    },
    gnCertificate: function(photo,name,organization){ 
        var bzjg=CurrentUser.category==30?"颁证机构"+ organization:"Authorized Organization"+ organization;
    	certificate = 	'<div class="ub ub-f1 ubb b_gra up1">' + 
						'	<div class="ub-img1 uw45 uh8" style="background-image:url(' + photo + ')"></div>' + 
						'	<div class="ub ub-f1 ub-ver">' + 
						'		<div class="upp5 ut-s">' + name + '</div>' + 
						'		<div class="ub ufp7 upp5 ub-ac ub-pc">' + 
						'			<div class="ub-img1 uw1 uh1 im_teacher"></div>' + 
						'			<div class="ub-f1 ut-s">　' + bzjg + '</div>' + 
						'		</div>' + 
						'	</div>' + 
						'</div>';
		return 	certificate;			
    },
	gnCourse: function(photo,name,teachername,classhour,des,id,callback){
	    var teacher=CurrentUser.category==30?"讲师"+ teachername:"lecturer"+ teachername;
	    var ks=CurrentUser.category==30?"课时"+ classhour:"Class"+ classhour; 
		var course ='<div data-id="' + id + '" class="ub ub-f1 ubb b_gra up1" ontouchstart="zy_touch()" onclick="' + callback + '">' + 
					'	<div class="ub-img1 uw45 uh8" style="background-image:url(' + photo + ')"></div>' + 
					'	<div class="ub ub-f1 ub-ver">' + 
					'		<div class="upp5 ut-s">' + name + '</div>' + 
					'		<div class="ub ufp7">' + 
					'			<div class="ub-f1 ub upp5 ub-ac ub-pc">' + 
					'				<div class="ub-img1 uw1 uh1 im_teacher"></div>' + 
					'				<div class="ub-f1">' + teacher + '</div>' + 
					'			</div>' + 
					'			<div class="ub-f1 ub upp5 ub-ac ub-pc">' + 
					'				<div class="ub-img1 uw1 uh1 im_teacher"></div>' + 
					'				<div class="ub-f1"> ' + ks + '</div>' + 
					'			</div>' + 
					'		</div>' + 
					'		<div class="ufp7 upp5 t-gra">' + des + '</div>' + 
					'	</div>' + 
					'</div>';
		return course;			
	}
}

var Menu = {
	20:{
		title:"老外",
		tab: [
			/*["set", "个人中心"],
			["course", "加州英语"],
			["chat", "聊天"],
			["address", "通讯录"],
			["event", "活动信息"],
			["newperson", "新人大本营"],
			["findjob", "寻找工作"],
			["news", "新闻"]*/
			["set", "Me"],
            ["course", "Cali-English"],
            ["event", "Activities"],
            ["news", "News"],
            ["findjob", "Jobs"],
            ["newperson", "I Need Help"],
            ["chat", "Chats"],
            ["address", "Contacts"]
		]
	},
	30:{
		title:"中国人",
		tab: [
		    /*["teacher", "滴滴外教"],*/
			["set", "个人中心"],
			["course", "加州英语"],
			["event", "老外的活动"],
			["findjob","工作机会"],
			["news", "英语新闻"],
			["newperson","帮助老外"],
			["chat", "聊天"],
			["address", "通讯录"]
			
		]
	}
}

var Role = { //用户类型
    TYPE_ADMIN: 0, //系统管理员
    TYPE_OPERATION: 10, //数据管理人员
    TYPE_FOREIGNER: 20, //外国人
    TYPE_CHINESE: 30, //中国人
};
var EVENTTYPE = {
    TYPE_JOB: 0,  //工作
    TYPE_TOPIC: 1, //英语主题活动
    TYPE_COURSE: 2, //主题课
    TYPE_OUTING: 3, //郊游
    TYPE_FOOT: 4, //徒步
    TYPE_CYCLE: 5, //骑车
    TYPE_FORUM: 6, //论坛
    TYPE_DEBATE: 7, //辩论赛
};
var LANGUAGE = {
	CHINESE: 0,
	ENGLISH: 1
};

var BROADCASTTYPE = {
    TYPE_NEWPERSON: 0,  //我是新人,发布在新人大本营
    TYPE_ENGLISH: 1,    //外教
    TYPE_GUIDE: 2, //导游
    TYPE_HOST: 3, //主持人
    TYPE_ACCOMPANY: 4, //陪同
};

var BROADCity = {
    BeiJing: 0,  //北京
    ShangHai: 1,    //上海
    GuangZhou: 2, //广州
    ShenZhen: 3, //深圳
    Others: 4, //其它
};

// var NATRUE = {
    // Full Time: 0,  //全职
    // Part Time: 1,    //兼职
// };
// 
// var REQUIRE = {
    // Apply for a job: 0,  //招聘
    // Recruitment: 1,    //应聘
// };
// 
// var LEVLE = {
    // Low: 0,  //低
    // Middle: 1,    //中
    // High: 2, //高
// };
// 
// var POST = {
    // English Teacher: 0,  //英语老师
    // DJ: 1,    //DJ
    // PR Manager: 2, //公共关系经理
    // Writer&Editor: 3, //编辑&写作
    // Marketing Manager: 4, //市场拓展经理
    // Others:5,        //其它
// };



var STATUSTYPE = {
    TYPE_ENROLL: 0, //报名
    TYPE_ATTEND: 1, //参加
};
var FRIENDSTATUS = {
    //0:正在请求 1:同意 2:拒绝 
    PEDDING: 0,
    AGREE: 1,
    REFUSE: 2,
    REMOVE: 3,
};
var CH_EN = {
	phone:["手机号/Mobile No","phone"],
	password:["密码/Password","password"],
	login:["登　录/Log in","login"],
	register:["注册用户/Register　","Register　"],
	findpass:["找回密码/Retrieve Password","|　Retrieve password"],
	phoneNotNull:["手机号不能为空/Phone number can not be empty","Phone number can not be empty"],
	passwordNotNull:["密码不能为空/Password can not be empty","Password can not be empty"]
}
var jobArr = ["英语老师","DJ","模特","编辑&写作","市场拓展经理","其他"];
var jobArr1 = ["Foreign Teacher","Tourist Guide","Host","Accompany","Others"];
var jobArr2 = ["English Teacher","DJ","Model","Writer&Editor","Marketing Manager","Others"];
var jobArr3 =["Full Time","Part Time"];
var jobArr4 =["全职","兼职"];
var jobArr5 =["Recruitment","Apply for a job"];
var jobArr6 =["低","中","高"];
var jobArr7 =["Low","Middle","High"];
var addressArr = ["北京","上海","广州","深圳"];
var addressArr1 = ["Bei Jing","Shang Hai","Guang Zhou","Shen Zhen","Others"];
var eventArr = ["英语主题活动","主题课","郊游","徒步","骑车","论坛","辩论赛"];
var eventArr1 = ["Expats Activities","Topic","Picnic","Hiking","Riding","Forum","Debate","Others"];
var eventArr2 = ["Hiking","Chinese Corner","English Corner","Product Promotion","Others"];
var eventArrText = {1:"英语主题活动",2:"主题课",3:"郊游",4:"徒步",5:"骑车",6:"论坛",7:"辩论赛"};
var eventArrText1 = {0:"Expats Activities",1:"Topic",2:"Picnic",3:"Hiking",4:"Riding",5:"Forum",6:"Debate"};